<?php 
header("content-type: text/html; charset=utf-8");
?>

<p>
	<h3>foreach</h3>
<?php 

$array = array("a"=>1, "b"=>2);

foreach($array as $value) {
	echo "value$value<br/>";
}

foreach($array as $key=>$value) {
	echo "$key=>$value<br/>";
}

?>
</p>

<p>
	<h3>static and global</h3>
<?php 

$global_x = 0;

function scope_test() {
	static $count = 0;	
	global $global_x;
	
	$count++;
	$global_x++;
	
	echo "$count, $global_x<br/>";
}
scope_test();
scope_test();

?>
</p>

<p>
	<h3>变量的变量</h3>
<?php 
$name = "Tom";
$$name = "I am tom";

echo $$name."<br/>";
echo $Tom."<br/>";
?>
</p>

<p>
	<h3>常量</h3>
<?php 
define("HAPPY", "幸福");

echo HAPPY."<br/>";
?>
</p>

<p>
	<h3>字符串插入</h3>
<?php 
$name = "Tom";
$$name = "I am tom";

echo "$Tom,${$name},{$$name}<br/>";
?>
</p>

<p>
	<h3>比较运算</h3>
<?php 
echo (1 != "1");
echo (1 <> "1");
echo (1 !== "1");
?>
</p>

<p>
	<h3>here字符串</h3>
<?php 
echo <<<DOC
段
光
伟
DOC;
?>
</p>

<p>
	<h3>函数级别的作用域</h3>
<?php 
for($i = 1; $i <= 10; $i++) {	
}

echo $i;
?>
</p>

<p>
	<h3>list接受函数返回的数组</h3>
<?php 
function muti_return() {
	return array(1, 2);	
}

list($x, $y) = muti_return();

echo"($x, $y)";
?>
</p>